package com.google.code.ptrends.Application.DAL.entities;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table (name="APP.PRICES")
public class PriceEntity {

	private int id;
	private ItemEntity item;
	private SupplierEntity supplier;
	private Date priceDate;
	private String price;

	public void setId(int id) {
		this.id = id;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public int getId() {
		return id;
	}

	public void setItem(ItemEntity item) {
		this.item = item;
	}

	@ManyToOne
	@Embedded
	@JoinColumn(name = "ITEM_ID", nullable = false)
	public ItemEntity getItem() {
		return item;
	}

	public void setSupplier(SupplierEntity supplier) {
		this.supplier = supplier;
	}

	@ManyToOne
	@Embedded
	@JoinColumn(name = "SUPPLIER_ID", nullable = false)
	public SupplierEntity getSupplier() {
		return supplier;
	}
	
	public void setPriceDate(Date priceDate) {
		this.priceDate = priceDate == null ? null : new Date(
				priceDate.getTime());
	}
	
	@Column(name = "PRICE_DATE", nullable = false)
	public Date getPriceDate() {
		Date cloned = null;
		if (priceDate != null) {
			cloned = new Date(priceDate.getTime());
		}
		return cloned;
	}
	
	public void setPrice(String price) {
		this.price = price;
	}
	
	@Column(name = "PRICE", nullable = false)
	public String getPrice() {
		return price;
	}
	
}
